package com.stagewebserver.webserver.utils;

import com.stagewebserver.webserver.service.impl.LikesServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;

/**
 * @author: yxl
 * @since: 2022-04-18
 **/
@Slf4j
@Component
public class LikeTask extends QuartzJobBean {

    @Autowired
    LikesServiceImpl likesService;

    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        likesService.transLikedFromRedisToDB();
        likesService.transLikedCountFromRedisToDB();
    }
}
